﻿using System;

namespace RDS.Core
{
    /// <summary>
    /// 前端任务展示数据体
    /// </summary>
    public class RunTask
    {
        /// <summary>
        /// 工作项编号
        /// </summary>
        public string ID { get; set; }
        /// <summary>
        /// 工作项类型
        /// </summary>
        public string Type { get; set; }
        /// <summary>
        /// 备注/任务流水号
        /// </summary>
        public string Comment { get; set; }
        /// <summary>
        /// 任务来源 也作为前端双击展示日志的文件名称
        /// </summary>
        public string Tag { get; set; }
        /// <summary>
        /// 工作项名称/来源CP名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 当前状态 0 启动 1 排队 2 执行中 3 挂起 4 入库 5 完成 6 废弃 7 链路超时 8 配置异常 9 任务超时 其它值 异常
        /// </summary>
        public int State { get; set; }
        /// <summary>
        /// 状态展示名称
        /// </summary>
        public string StateName
        {
            get {
                string _name = string.Empty;
                switch (State)
                {
                    case 0:
                        _name = "启动";
                        break;
                    case 1:
                        _name = "排队";
                        break;
                    case 2:
                        _name = "执行中";
                        break;
                    case 3:
                        _name = "挂起";
                        break;
                    case 4:
                        _name = "入库";
                        break;
                    case 5:
                        _name = "完成";
                        break;
                    case 6:
                        _name = "取消";
                        break;
                    case 7:
                        _name = "链路超时";
                        break;
                    case 8:
                        _name = "配置异常";
                        break;
                    case 9:
                        _name = "任务超时";
                        break;
                    default:
                        _name = "异常";
                        break;
                }
                return _name;
            }
        }
        /// <summary>
        /// 工作项创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 工作项完成时间 默认用最大日期填充
        /// </summary>
        public DateTime EndTime { get; set; } = DateTime.MaxValue;
    }
}
